﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel;
using System.Reflection;
using QDT.Web.GenerageRodomKey;

namespace QDT.Web.HanXinPlantFormInfo
{
    public class PlantFormInfo
    {
        /// C#中的结构体很奇怪的，必须定结构体和元素都必须定义为public，默认是private，否则在本类中都不能使用
        /// 它和类很相似，所以必须用public类型，如果元素定义为static时，就不用实例化，可以直接访问
        public struct UserInfo
        {
            ///由翰鑫科技验证平台在渠道入网后分配给渠道，不能更改
            public const string channelId = "11008009";
            public const string transCode = "1001";
            public const string channelName = "QDT身份实名验证系统";
            
            /// public static string channelOrderId = "6";
            // 银行卡号#信用卡)|用户姓名|身份证号|手机号|IMEI|终端编号|LBS|IP|身份证图片代码
            public static string BankCard;
            public static string UserName;
            public static string ID;
            public static string PhoneNum;
            /// 翰鑫科技平台目前还用不到这个参数
            /// public static string IMEI;
            /// public static string TerminalCode;
            public static string LBS;
            /// 翰鑫科技平台目前还用不到这个参数
            /// public static string IP;
            public static string IDImgCode;
        };
        /// <summary>
        /// C#中的枚举只能是值类型，不能是字符，如果要使用字符就要自己转换，或者用Description类
        /// </summary> 
        public enum checkCodeTable
        {
            [Description("验证（卡号，姓名）")]
            BankCard_UserName = 100046,
            [Description("验证（卡号，手机号）")]
            BankCard_PhoneNum = 100047,
            [Description("验证（姓名，身份证号）")]
            UserName_ID = 100048,
            [Description("验证（卡号，姓名，身份证号）")]
            BankCard_UserName_ID = 100056,
            [Description("验证（卡号，姓名，身份证号，手机号）")]
            BankCard_UserName_ID__PhoneNum = 100060,
            [Description("验证（姓名，身份证号，身份证图片代码）")]
            UserName_ID_IDImgCode = 100050,
            [Description("验证（卡号，姓名，身份证号，手机号，身份证图片代码）")]
            BankCard_UserName_ID_PhoneNum_IDImgCode = 100062,
            [Description("验证（卡号，姓名，身份证号，手机号，短信，身份证图片代码）（未实现）")]
            BankCard_UserName_ID_PhoneNum_Msg_IDImgCode = 100063
        }
        public static string GetFactorsUserNameID(string _userName, string _ID)
        {
            string strResult = "Error";
            /// 验证，已成功，实人认证错误（收费）
            /// |用户姓名|身份证号||||||
            UserInfo.UserName = _userName;
            UserInfo.ID = _ID;
            strResult = "|" + UserInfo.UserName + "|" + UserInfo.ID + "||||||";
            
            return strResult;
        }
        public static string GetFactorsAll(int checkCode)
        {
            string strResult = "Error";
            // 必须要强制转换为int
            if (checkCode == (int)checkCodeTable.BankCard_UserName)
            {
                /// 验证，未通过
                /// 返回其它的错误信息，没有相应应答码，验证套餐输入格式错误，当然是不收费的！
                /// 银行卡号|用户姓名|||||||;
                /// 必须要注意，银行卡在前，信用卡在后
                UserInfo.BankCard = "621226240201556100";
                UserInfo.UserName = "张三";
                strResult = UserInfo.BankCard + "|" + UserInfo.UserName + "|||||||";
            }
            else if (checkCode == (int)checkCodeTable.BankCard_PhoneNum)
            {
                /// 验证，未通过
                /// 返回其它的错误信息，没有相应应答码，验证套餐输入格式错误，当然是不收费的！
                /// 银行卡号|||手机号|||||
                UserInfo.BankCard = "621226240201556100";
                UserInfo.PhoneNum = "18798705783";
                strResult = UserInfo.BankCard + "|||" + UserInfo.PhoneNum + "|||||";
            }
            else if (checkCode == (int)checkCodeTable.UserName_ID)
            {
                /// 验证，已成功，实人认证错误（收费）
                /// |用户姓名|身份证号||||||
                UserInfo.UserName = "张三";
                UserInfo.ID = "522324198801244011";
                strResult = "|" + UserInfo.UserName + "|" + UserInfo.ID + "||||||";
            }
            else if (checkCode == (int)checkCodeTable.BankCard_UserName_ID)
            {
                /// 银行卡未加入超级网银系统，不支持验证，不支持该银行卡验证（不收费）
                /// 银行卡号|用户姓名|身份证号||||||
                UserInfo.BankCard = "621226240201556100";
                UserInfo.UserName = "张三";
                UserInfo.ID = "522324198801244011";
                strResult = UserInfo.BankCard + "|" + UserInfo.UserName + "|" + UserInfo.ID + "||||||";
            }
            else if (checkCode == (int)checkCodeTable.BankCard_UserName_ID__PhoneNum)
            {
                /// 银行卡未加入超级网银系统，不支持验证，不支持该银行卡验证（不收费）
                /// 银行卡号|用户姓名|身份证号|手机号|||||
                UserInfo.BankCard = "621226240201556100";
                UserInfo.UserName = "张三";
                UserInfo.ID = "522324198801244011";
                UserInfo.PhoneNum = "18798705783";
                strResult = UserInfo.BankCard + "|" + UserInfo.UserName + "|" + UserInfo.ID + "|" + UserInfo.PhoneNum + "|||||";
            }
            else if (checkCode == (int)checkCodeTable.UserName_ID_IDImgCode)
            {
                /// 验证，已成功，实人认证错误（收费）
                //|用户姓名|身份证号||||||身份证图片代码
                UserInfo.UserName = "陈波";
                UserInfo.ID = "522324198801244011";
                UserInfo.IDImgCode = "9090093";
                strResult = "|" + UserInfo.UserName + "|" + UserInfo.ID + "||||||" + UserInfo.IDImgCode;
            }
            else if (checkCode == (int)checkCodeTable.BankCard_UserName_ID_PhoneNum_IDImgCode)
            {
                /// 银行卡未加入超级网银系统，不支持验证，不支持该银行卡验证（不收费）
                /// 银行卡号|用户姓名|身份证号|手机号|||||身份证图片代码
                UserInfo.BankCard = "621226240201556100";
                UserInfo.UserName = "张三";
                UserInfo.ID = "522324198801244011";
                UserInfo.PhoneNum = "18798705783";
                UserInfo.IDImgCode = "9090093";
                strResult = UserInfo.BankCard + "|" + UserInfo.UserName + "|" + UserInfo.ID + "|" +
                            UserInfo.PhoneNum + "|||||" + UserInfo.IDImgCode;
            }
            /// 验证（卡号，姓名，身份证号，手机号，短信，身份证图片代码）（未实现）
            else if (checkCode == (int)checkCodeTable.BankCard_UserName_ID_PhoneNum_Msg_IDImgCode)
            {
                /// 翰鑫科技平台本来就没实现
                /// 银行卡号|用户姓名|身份证号|手机号|||LBS||身份证图片代码
                UserInfo.BankCard = "89993883399";
                UserInfo.UserName = "张三";
                UserInfo.ID = "89989977889";
                UserInfo.PhoneNum = "1909873993";
                UserInfo.LBS = "dfdfd";
                UserInfo.IDImgCode = "9090093";
                strResult = UserInfo.BankCard + "|" + UserInfo.UserName + "|" + UserInfo.ID + "|" +
                            UserInfo.PhoneNum + "|||" + UserInfo.LBS + "|" + UserInfo.IDImgCode;
            }
            return strResult;
        }
        public static string GetDescription(Enum value)
        {
            FieldInfo fi = value.GetType().GetField(value.ToString());
            DescriptionAttribute[] attributes =
                  (DescriptionAttribute[])fi.GetCustomAttributes(
                  typeof(DescriptionAttribute), false);
            return (attributes.Length > 0) ? attributes[0].Description : value.ToString();
        }
    }
}